package com.ljf.tijian.controller;

import com.ljf.tijian.ApiResponse;
import com.ljf.tijian.pojo.Orders;
import com.ljf.tijian.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrdersController {

    @Autowired
    OrdersService ordersService;

    @RequestMapping("/createOrder")
    public ApiResponse createOrder(@RequestBody Orders orders){
        System.out.println(orders.toString());
        return ordersService.createOrder(orders);
    }

    @RequestMapping("/countOrder")
    public ApiResponse countOrder(){
        return ordersService.selectAllOrdersForSmId();
    }

    @RequestMapping("/countOrderForHp")
    public ApiResponse countOrderForHp(){
        return ordersService.selectAllOrdersForHpId();
    }

    @RequestMapping("/queryAppointmentByUser")
    public ApiResponse queryAppointmentByUser(@RequestBody Orders orders){
        return ordersService.queryAppointmentByUser(orders);
    }

    @RequestMapping("/cancelOrderByOrderId")
    public ApiResponse cancelOrderByOrderId(@RequestBody Orders orders){
        return ordersService.cancelOrder(orders);
    }

}
